#! /usr/bin/env python
#coding=utf-8

import random
import string
import math
import sys
 
DEBUG = False
 
def nextprime(n):
    i = n + 1 - n%2
    while not probably_prime(i):
        i+=2
    return i
    #i = n + 1 - n%2
    #m = 2*n
    #while i < m:
    #    if probably_prime(i):
    #        return i
    #    i+=2
 
def toBinary(n):
    r = []
    while (n > 0):
        r.append(n % 2)
        n = n / 2
    return r
 
def test(a, n):
    """
    Returns:
      - True, if n is complex.
      - False, if n is probably prime.
    """
    b = toBinary(n - 1)
    d = 1
    for i in xrange(len(b) - 1, -1, -1):
        x = d
        d = (d * d) % n
        if d == 1 and x != 1 and x != n - 1:
            return True
        if b[i] == 1:
            d = (d * a) % n
    if d != 1:
        return True # Complex
    return False # Prime
 
def MillerRabin(n, s = 15):
    """
      Returns:
        - True, if n is probably prime.
        - False, if n is complex.
    """
    for j in xrange(1, s + 1):
        a = random.randint(1, n - 1)
        if (test(a, n)):
            return False # n is complex
    return True # n is prime
 
def probably_prime(n):
    return MillerRabin(n)
 
 
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m
 
 
def genkey(bits=100):
    BIG_NUM = []
    P_INT = 0
    Q_INT = 0
    global P, Q, X, N, D, E
 
    for i in range(bits):
        BIG_NUM.append(random.choice('0123456789'))
 
    P_INT = int(''.join(BIG_NUM))
 
    for i in range(bits):
        BIG_NUM[i] = random.choice('0123456789')
 
    Q_INT = int(''.join(BIG_NUM))
 
    if DEBUG:
        print "p=%d"%P_INT
        print "q=%d"%Q_INT
 
    P = nextprime(P_INT)
    Q = nextprime(Q_INT)
 
    if DEBUG:
        print "next prime to p is %d"%P
        print "next prime to q is %d"%Q
 
    N = P*Q
    if DEBUG:
        print "n=%d"%N
 
    X = (P-1)*(Q-1)
    if DEBUG:
        print "x=%d"%X
 
    while True:
        if gcd(X, E)==1:
            break
        E+=2
 
    if DEBUG:
        print "e=%d"%E
 
    n = 1
    while (n*X+1)%E!=0:
        n+=1
    D = (n*X+1)/E
 
    if DEBUG:
        print "d=%d"%D
 
def rsa_encrypt(msg):
    enc = []
    for c in msg:
        enc.append(pow(ord(c), E, N))
    return enc
 
def rsa_decrypt(cmsg):
    dec = []
    tmp = []
    for ec in cmsg:
        tmp.append(pow(ec, D, N))
    for c in tmp:
        dec.append("%c"%c)
    return dec
 
X = N = D = P = Q = 0
E= 65537
 
if __name__=="__main__":
    DEBUG = True
 
    argc = len(sys.argv)
    if argc==1:
        genkey()
    elif argc==2:
        genkey(string.atoi(sys.argv[1]))
    else:
        sys.exit(-1)
 
    msg = raw_input()
    enc = rsa_encrypt(msg)
    if DEBUG:
        print enc
    dec = rsa_decrypt(enc)
    print ''.join(dec)
